<script>
function load_member_page(){
	$('#firstclass').html('<img style=\'margin-top:100px;\' src=\'images/loading.gif\' align="absmiddle"/>'); 
	$.get(
		'firstclass_inquiry_ajax.php',
		function(data){
			$('#firstclass').html(data).hide().fadeIn('fast');;
			$('ul#icons li').hover(
				function() { $(this).addClass('ui-state-hover'); }, 
				function() { $(this).removeClass('ui-state-hover'); 
			});
	});
}
$(function(){
	load_member_page();
	$('#keyword').keyup(function() {
		$('#firstclass').html('<img style=\'margin-top:100px;\' src=\'images/loading.gif\' align="absmiddle"/>'); 
		$.post("firstclass_inquiry_ajax.php", { keyword: $("#keyword").val()}, 
			function(data){
				$("#firstclass").html(data);
			}
		);
	});
	
	$('#status').change(function(){
		$('#firstclass').html('<img style=\'margin-top:100px;\' src=\'images/loading.gif\' align="absmiddle"/>'); 
		$.get('firstclass_inquiry_ajax.php',{status:$('#status').val()},
			function(data){
				$("#firstclass").html(data);
		});
	});
	
});

function active(id,status)
{
	$("#dialog_active").dialog({
		modal: true,
		buttons: {
			ตกลง: function() {
					$.get(
						'member_control.php',
						{id:id,status:status,action:'inquiry_active'},
						function(data){
							if(status == 'online'){
								$('#active'+id).html("<a onclick=\"active("+id+",'offline')\" href=\"javascript:void(0);\"><span style=\"color:black;\">ยังไม่ติดต่อ</span></a>").hide().fadeIn('slow');
							}else{
								$('#active'+id).html("<a onclick=\"active("+id+",'online')\" href=\"javascript:void(0);\"><span style=\"color:green;\">ติดต่อแล้ว</span></a>").hide().fadeIn('slow');
							}
					});
					$( this ).dialog( "close" );
				},
			ยกเลิก:function() {
					$( this ).dialog( "close" );
				}
		}
	});
}
function ViewInquiry(id)
{
	$('#member_dialog').html('<img style=\'margin-top:100px;\' src=\'images/loading.gif\' align="absmiddle"/>'); 
	$.get(
		'firstclass_inquiry_view.php',
		{id:id},
		function(data){
			$('#member_dialog').html(data);
		}
	);
	$("#member_dialog").dialog({
		modal: true,
		width:500,
		height:700,
		position:'top',
		buttons: {
			ปิด:function(){
				$( this ).dialog( "close" );
			}
		}
	});
}
function DeleteMember(id)
{
	$("#dialog2").dialog({
		modal: true,
		width:400,
		buttons: {
			ตกลง: function(){
				$.get('member_control.php',{id:id,action:'delete_inquiry'},function(data){load_member_page();});
				$( this ).dialog( "close" );
			},
			ยกเลิก:function(){
				$( this ).dialog( "close" );
			}
		}
	});
}
</script>
<div id="dialog_active" title="ข้อความ"  style="display:none;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>ต้องการเปลี่ยนสถานะ?</p>
</div>
<div id="dialog2" title="ข้อความ"  style="display:none;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>ต้องการลบข้อมูล?</p>
</div>
<div id="member_dialog" title="ข้อมูลผู้เอาประกัน"  style="display:none;"></div>
<div id="tabs">
    <ul>
    	<li><a class="head_tab" style="padding-left:7px;" href="#tabs-1"><span class="ui-icon ui-icon-comment" style="float:left;"></span>สอบถามประกันชั้น 1</a></li>   
    </ul>
    <div id="tabs-1">
    	<ul id="panel">
            	<li><input type="text" id="keyword" name="keyword"  value="ค้นหาสมาชิก" onfocus="this.value=''"/></li>
                <li><select id="status"><option value="" selected="selected">เลือกสถานะ</option><option value="1">ติดต่อแล้ว</option><option value="0">ยังไม่ติดต่อ</option></select></li>
                <div style="clear:both;"></div>
            </ul>
    	<div id="firstclass" align="center"></div>          
    </div>
</div>            